package runner;


import drivers.PointEventCommandDriver;
import drivers.PointMDCommandDriver;
import net.socket.driver.providers.MDCommandDriverProvider;
import net.socket.share.ServerRunner;
import net.socket.wareable.SnowflakeId;
import register.RountRegisterInfo;

import java.io.IOException;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @Author: Qiao Hang
 * @CreateDate: 2021/3/18 下午2:09
 * @UpdateDate:
 * @Description:
 */
public class Server {

    private static ThreadPoolExecutor pool = new ThreadPoolExecutor(
            10,
            100,
            10, TimeUnit.MINUTES,
            new LinkedBlockingQueue<>()
    );

    public static void main(String[] args) throws IOException, InterruptedException {
        ServerRunner.builder(4477,4478)
                .idWorker(new SnowflakeId(3,1))
                .registerInfoModel(RountRegisterInfo.class)
                .resourceResolveTriggerCorn("*/30 * * * * ?")
                .resourceResolveDelaySecond(3*60)
                .threadPool(pool)
                .addMDDriverProviders(new MDCommandDriverProvider(){{
                    add(new PointMDCommandDriver());
                }})
                .addEventDrivers(new PointEventCommandDriver())
                .run();
    }
}
